/**
 * Author: runlin.tang
 * Creation Time: 2016-06-29.
 * Description:.����管理页面状态信息获取接口
 */
define(['jquery','../../common/ajax/ajax'],
    function($,ajax) {
        function example(){
            ajax({
                url:interfaces.getManageStatue.url,
                dataType:interfaces.getManageStatue.dataType,
                type:interfaces.getManageStatue.type,
                data:{},
                cache:{
                    use:false,
                    name:'',
                    time:10
                },
                isOk:function(data){
                    var datas = '';
                    if(useNetData){
                        datas = data;
                    }else{
                        datas = data.admin;
                    }

                    var htmls = '';
                    var shoopname = '';
                    var welcome = '';
                    var apk_version = '';
                    var cgi_version = '';
                    var nuller = 0;
                    if(datas.data.shop_info != 'null'){
                        shoopname = '<i>获取门店信息</i><span>'+datas.data.shop_info+'<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        shoopname = '<i>获取门店信息</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".one-device>li").eq(0).html(shoopname);
                    if(datas.data.welcome_version != 'null'){
                        welcome = '<i>获取门店欢迎页</i><span>'+datas.data.welcome_version+'<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        welcome = '<i>获取门店欢迎页</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".one-device>li").eq(1).html(welcome);
                    if(datas.data.apk_version != 'null'){
                        apk_version = '<i>获取门店App</i><span>'+datas.data.apk_version+'<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        apk_version = '<i>获取门店App</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".one-device>li").eq(2).html(apk_version);
                    if(datas.data.cgi_version != 'null'){
                        cgi_version = '<i>获取门店CGI</i><span>'+datas.data.cgi_version+'<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        cgi_version = '<i>获取门店CGI</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".one-device>li").eq(3).html(cgi_version);
                    var gujian = '';
                    if(datas.data.firmware_version != 'null'){
                        gujian = '<i>固件版本</i><span>'+datas.data.firmware_version+'<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        gujian = '<i>固件版本</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".two-device>li").eq(0).html(gujian);
                    var tf = '';
                    if(datas.data.TF_statue != 'null'){
                        tf = '<i>TF卡状态</i><span>正常<img style="margin-top:0.2rem;" src="images/router/ic_state_correct.png"></span>';
                    }else{
                        tf = '<i>TF卡状态</i><span>未知<img src="images/router/ic_state_error.png" height="26" width="37"></span>';
                        nuller = nuller+1;
                    }
                    $(".two-device>li").eq(1).html(tf);

                    if(nuller>0){
                        $(".state-admin").attr('class','state-admin abnormal').html('系统异常，请拨打<a href="tel:4008077067" style="color:#fff"> 4008 077 067</a>');
                    }else{
                        $(".state-admin").attr('class','state-admin normal').html('系统准备完毕，可以线装!');
                    }
                    $(".self-check").find('i').html('上次检查时间：'+datas.data.time);
                    $(".self-check").find('a').addClass('reloads');
                    $(".reloads").click(function(){
                        example();
                    });
                }
            });
        }
        return example;
    });